package com.leji.song.mine;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;

import android.widget.TextView;
import com.dgl.sdk.util.SharePreStore;
import com.leji.song.R;
import com.leji.song.extra.BaseActivity;
import com.leji.song.util.ActivityStackControlUtil;
import com.leji.song.util.ConstAns;

/**
 * Created by colin.ding on 2014/6/4.
 */
public class MineActivity extends BaseActivity{

    private final static String SERVICE_NUM = "13888888888";

    private TextView myPhone;
    private View callService;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mine);

        initView();
    }

    private void initView() {
        setActivityTitle("我的");

        myPhone = (TextView) findViewById(R.id.myPhone);
        callService = (View) findViewById(R.id.callService);

        myPhone.setText(SharePreStore.readString(ConstAns.MY_PHONE));

        callService.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + SERVICE_NUM));
                startActivity(intent);
            }
        });
    }

    public void gotoAdressManager(View v){
    	showActivity(AdressManagerActivity.class);
    }

    private long exitTime;
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK ) {
            if((System.currentTimeMillis() - exitTime) > 2000){
                showToast("再按一次退出掌上学苑");
                exitTime = System.currentTimeMillis();
            } else {
                ActivityStackControlUtil.finishProgram();
            }
        }

        return true;
    }
}
